package com.isoft.entity;

import com.fasterxml.jackson.annotation.JsonProperty;
import jakarta.xml.bind.annotation.*;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

@Data
@XmlRootElement(name = "MSG")
@XmlAccessorType(XmlAccessType.FIELD)
public class DfmePokeEntity {
    @JsonProperty("meta")
    @XmlElement(name = "META")
    private Meta meta;

    @JsonProperty("dflt")
    @XmlElement(name = "DFLT")
    private Dflt dflt;

    @JsonProperty("routes")
    @XmlElementWrapper(name = "ROUTES")
    @XmlElement(name = "ROUTE")
    private List<Route> routes = new ArrayList<>();

    @JsonProperty("gates")
    @XmlElementWrapper(name = "GATES")
    @XmlElement(name = "GATE")
    private List<Gate> gates = new ArrayList<>();

    @JsonProperty("counters")
    @XmlElementWrapper(name = "COUNTERS")
    @XmlElement(name = "COUNTER")
    private List<Counter> counters = new ArrayList<>();

    @JsonProperty("baggage")
    @XmlElement(name = "BAGGAGE")
    private Baggage baggage;

    @JsonProperty("irregularity")
    @XmlElement(name = "IRREGULARITY")
    private Irregularity irregularity;

    @JsonProperty("boardingTimes")
    @XmlElementWrapper(name = "BOARDING_TIMES")
    @XmlElement(name = "TIME")
    private List<BoardingTime> boardingTimes = new ArrayList<>();

    @JsonProperty("sharedFlights")
    @XmlElementWrapper(name = "SHARED_FLIGHTS")
    @XmlElement(name = "SHARED_FLIGHT")
    private List<SharedFlight> sharedFlights = new ArrayList<>();

    @JsonProperty("specialPassengers")
    @XmlElement(name = "SPECIAL_PASSENGERS")
    private SpecialPassengers specialPassengers;

    @JsonProperty("aircraft")
    @XmlElement(name = "AIRCRAFT")
    private Aircraft aircraft;

    @JsonProperty("arrival")
    @XmlElement(name = "ARRIVAL")
    private Arrival arrival;

    public Meta getMeta() {
        return meta;
    }

    public void setMeta(Meta meta) {
        this.meta = meta;
    }

    public Dflt getDflt() {
        return dflt;
    }

    public void setDflt(Dflt dflt) {
        this.dflt = dflt;
    }

    @Data
    @XmlAccessorType(XmlAccessType.FIELD)
    public static class Meta {
        @XmlElement(name = "SNDR")
        private String sender;
        @XmlElement(name = "RCVR")
        private String receiver;
        @XmlElement(name = "SEQN")
        private Long sequenceNumber;
        @XmlElement(name = "DDTM")
        private String dateTime;
        @XmlElement(name = "TYPE")
        private String type;
        @XmlElement(name = "STYP")
        private String subType;
        @XmlElement(name = "ORIG")
        private String origin;
        @XmlElement(name = "PRIO")
        private String priority;
        private Long msgId;
        public Long getMsgId() {
            return msgId;
        }
        public void setMsgId(Long msgId) {
            this.msgId = msgId;
        }
    }

    @Data
    @XmlAccessorType(XmlAccessType.FIELD)
    public static class Dflt {
        @XmlElement(name = "FLID")
        private Long flightId;
        @XmlElement(name = "FFID")
        private String flightFileId;
        @XmlElement(name = "FIDE")
        private String flightIdentifier;
        @XmlElement(name = "FATT")
        private String flightAttribute;
        @XmlElement(name = "STAT")
        private String status;
        @XmlElement(name = "ISTA")
        private String internalStatus;
        @XmlElement(name = "POKT")
        private String pokeTime;
        @XmlElement(name = "MSTA")
        private String manualStatus;
        @XmlElement(name = "MIST")
        private String manualInternalStatus;
        @XmlElement(name = "MPOK")
        private String manualPoke;
        @XmlElement(name = "HBID")
        private String hbid;
        @XmlElement(name = "NFLN")
        private String nfln;
        @XmlElement(name = "NAWC")
        private String nawc;

        public String getStatus() {
            return status;
        }

        public void setStatus(String status) {
            this.status = status;
        }
    }

    @Data
    @XmlAccessorType(XmlAccessType.FIELD)
    public static class Route {
        @XmlElement(name = "APCD")
        private String airportCode;
        @XmlElement(name = "APNO")
        private Integer airportSequence;
        @XmlElement(name = "FPTT")
        private String scheduledTime;
        @XmlElement(name = "FETT")
        private String estimatedTime;
        @XmlElement(name = "FRTT")
        private String actualTime;
    }

    @Data
    @XmlAccessorType(XmlAccessType.FIELD)
    public static class Gate {
        @XmlElement(name = "NMCD")
        private String gateNumber;
        @XmlElement(name = "GTTY")
        private String gateType;
    }

    @Data
    @XmlAccessorType(XmlAccessType.FIELD)
    public static class Counter {
        @XmlElement(name = "FCES")
        private String counterNumber;
        @XmlElement(name = "FCST")
        private String startTime;
        @XmlElement(name = "FCEE")
        private String endTime;
        @XmlElement(name = "FCTY")
        private String counterType;
    }

    @Data
    @XmlAccessorType(XmlAccessType.FIELD)
    public static class Baggage {
        @XmlElement(name = "BTNO")
        private String beltNumber;
        @XmlElement(name = "CODE")
        private String beltCode;
        @XmlElement(name = "BTAT")
        private String beltAttribute;
        @XmlElement(name = "ESTR")
        private String estimatedStartTime;
        @XmlElement(name = "EEND")
        private String estimatedEndTime;
        @XmlElement(name = "RSTR")
        private String realStartTime;
        @XmlElement(name = "REND")
        private String realEndTime;
        @XmlElement(name = "BTSC")
        private String beltSection;
    }

    @Data
    @XmlAccessorType(XmlAccessType.FIELD)
    public static class Irregularity {
        @XmlElement(name = "ABST")
        private String abnormalStatus;
        @XmlElement(name = "ABRS")
        private String abnormalReason;
        @XmlElement(name = "IAST")
        private String internalStatus;
        @XmlElement(name = "IARS")
        private String internalReason;
        @XmlElement(name = "MABS")
        private String manualAbnormalStatus;
        @XmlElement(name = "MABR")
        private String manualAbnormalReason;
        @XmlElement(name = "MIAS")
        private String manualInternalStatus;
        @XmlElement(name = "MIAR")
        private String manualInternalReason;
    }

    @Data
    @XmlAccessorType(XmlAccessType.FIELD)
    public static class BoardingTime {
        @XmlElement(name = "BORT")
        private String boardingType;
        @XmlElement(name = "BORTT")
        private String boardingTime;
    }

    @Data
    @XmlAccessorType(XmlAccessType.FIELD)
    public static class SharedFlight {
        @XmlElement(name = "SFAW")
        private String airlineCode;
        @XmlElement(name = "SFNO")
        private String flightNumber;
    }

    @Data
    @XmlAccessorType(XmlAccessType.FIELD)
    public static class SpecialPassengers {
        @XmlElement(name = "VIP")
        private Integer vipCount;
        @XmlElement(name = "SPNC")
        private String specialNeeds;
    }

    @Data
    @XmlAccessorType(XmlAccessType.FIELD)
    public static class Aircraft {
        @XmlElement(name = "CFTP")
        private String aircraftType;
        @XmlElement(name = "CFNO")
        private String aircraftNumber;
    }

    @Data
    @XmlAccessorType(XmlAccessType.FIELD)
    public static class Arrival {
        @XmlElement(name = "APCD")
        private String airportCode;
        @XmlElement(name = "GATE")
        private String gate;
        @XmlElement(name = "STOP")
        private String stop;
    }
}